import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';

import 'package:get/get.dart';
import 'package:zrjz/comm/utils/ex_widget.dart';
import 'package:zrjz/comm/widget/no_shadow_scroll_behavior.dart';
import 'package:zrjz/generated/assets.dart';

import '../../constants/color_constants.dart';
import '../my_load_image.dart';
import '../my_text_view.dart';

class PartTimeApplyJobDialog extends StatelessWidget {
  VoidCallback? cancelAction;
  VoidCallback? confirmAction;
  String? cancemText;
  String? confirmText;
  String? title;
  String? jobTime;

  PartTimeApplyJobDialog( {this.jobTime,this.cancemText, this.cancelAction, this.confirmText, this.confirmAction, this.title});

  @override
  Widget build(BuildContext context) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.center,
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        //Title
        Container(
          decoration: const BoxDecoration(
            color: ColorConstants.appBlue,
            borderRadius: BorderRadius.only(
              topLeft: Radius.circular(5),
              topRight: Radius.circular(5),
            ),
          ),
          padding: const EdgeInsets.only(left: 30, right: 10, top: 5, bottom: 5),
          child: Row(
            children: [
              Expanded(
                child: MyTextView(
                  title ?? "提示".tr,
                  fontSize: 24,
                  marginTop: 14,
                  marginBottom: 14,
                  isFontBold: true,
                  textColor: ColorConstants.whitefe,
                  textAlign: TextAlign.center,
                ),
              ),
              //Cancel
              InkWell(
                onTap: onCancel,
                child: MyLoadImage(
                  Assets.imagesDialogDeleteIcon,
                  width: 26,
                  height: 26,
                ),
              ),
            ],
          ),
        ),

        DecoratedBox(
          decoration: const BoxDecoration(
            color: Colors.white,
            borderRadius: BorderRadius.only(
              bottomLeft: Radius.circular(5),
              bottomRight: Radius.circular(5),
            ),
          ),
          child: Column(
            children: [
              //文本的高度限制，加入滚动并去除边界波纹效果
              ScrollConfiguration(
                  behavior: NoShadowScrollBehavior(),
                  child: SingleChildScrollView(
                    child:           //Message
                    Container(
                      margin: EdgeInsets.only(top: 25, left: 30, right: 30,bottom: 25),
                      child: RichText(
                        textAlign: TextAlign.center,
                        text: TextSpan(
                            text: "您申请的工作时间为：".tr,
                            style: TextStyle(
                              color: ColorConstants.black,
                              fontSize: 16,
                              fontWeight: FontWeight.w400,
                            ),
                            children: [

                              TextSpan(
                                text: "${jobTime}",
                                style: TextStyle(
                                  color: ColorConstants.appRed,
                                  fontSize: 16,
                                  fontWeight: FontWeight.w400,
                                ),
                              ),

                              TextSpan(
                                text: "如果您没有出席这个工作，我们将收取您".tr,
                                style: TextStyle(
                                  color: ColorConstants.black,
                                  fontSize: 16,
                                  fontWeight: FontWeight.w400,
                                ),
                              ),

                              TextSpan(
                                text: "25",
                                style: TextStyle(
                                  color: ColorConstants.appRed,
                                  fontSize: 16,
                                  fontWeight: FontWeight.w400,
                                ),
                              ),

                              TextSpan(
                                text: "元的缺席费，是否同意并继续？".tr,
                                style: TextStyle(
                                  color: ColorConstants.black,
                                  fontSize: 16,
                                  fontWeight: FontWeight.w400,
                                ),
                              ),

                            ]),
                      ),
                    ),
                    // child: MyTextView(
                    //   message??"-",
                    //   fontSize: 16,
                    //   textColor: ColorConstants.black,
                    //   isFontMedium: true,
                    //   textAlign: TextAlign.center,
                    //   paddingLeft: 30,
                    //   paddingRight: 30,
                    //   paddingBottom: 25,
                    //   marginTop: 25,
                    // ),
                  )).marginSymmetric(vertical: 10).constrained(maxHeight: 400),

              //Buttons
              Row(
                children: [
                  Expanded(
                      flex: 4,
                      child: InkWell(
                        onTap: () {
                          onCancel();
                          cancelAction?.call();
                        },
                        child: MyTextView(
                          cancemText ?? "取消".tr,
                          marginLeft: 20,
                          marginBottom: 35,
                          paddingTop: 12,
                          paddingBottom: 12,
                          fontSize: 16,
                          isFontMedium: true,
                          textAlign: TextAlign.center,
                          textColor: ColorConstants.whitefe,
                          backgroundColor: ColorConstants.appBlue,
                          cornerRadius: 0,
                        ),
                      )),
                  Expanded(
                      flex: 7,
                      child: InkWell(
                        onTap: () {
                          onCancel();
                          confirmAction?.call();
                        },
                        child: MyTextView(
                          confirmText ?? "确定".tr,
                          marginLeft: 10,
                          paddingTop: 12,
                          paddingBottom: 12,
                          fontSize: 16,
                          isFontMedium: true,
                          marginRight: 20,
                          marginBottom: 35,
                          textAlign: TextAlign.center,
                          textColor: ColorConstants.whitefe,
                          backgroundColor: ColorConstants.appRed,
                          cornerRadius: 0,
                        ),
                      )),
                ],
              ),
            ],
          ),
        ),
      ],
    ).constrained(width: 295);
  }

  //取消弹框
  void onCancel() async {
    SmartDialog.dismiss();
  }
}
